class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
  before_filter CASClient::Frameworks::Rails::Filter unless Rails.env == 'test'
  skip_before_filter :verify_authenticity_token

  def logout
    CASClient::Frameworks::Rails::Filter.logout(self)
  end

  # for prototype
  class User
    attr_accessor :login, :name
    def initialize(opt={ })
      @login = opt[:login]
      @name = opt[:name]
    end
  end

  def current_user
    User.new(login: session[:login],
             name: session[:login_extra_attributes]['displayName'][0].force_encoding('utf-8'))
  end
end
